package adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import app.fitness.fragment.DashBoardFragment;
import app.fitness.simplefragment.DashBoardCaloriesSimpleFragment;
import app.fitness.simplefragment.DashBoardDetailCaloriesSimpleFragment;
import app.fitness.simplefragment.DashBoardDetailDistanceSimpleFragment;
import app.fitness.simplefragment.DashBoardDetailSleepSimpleFragment;
import app.fitness.simplefragment.DashBoardDetailStepsSimpleFragment;
import app.fitness.simplefragment.DashBoardDistanceSimpleFragment;
import app.fitness.simplefragment.DashBoardSleepSimpleFragment;
import app.fitness.simplefragment.DashBoardStepsSimpleFragment;
import app.fitness.simplefragment.WelcomeNabuSimpleFragment;
import define.DashBoard;
import define.Position;

public class CircleFragmentAdapter extends FragmentStatePagerAdapter {
	/**
	 * Decide how many view pager in here
	 */
	private int COUNT = 4;

	private Class<?> Class;

	public CircleFragmentAdapter(FragmentManager fm, Class<?> Class) {
		super(fm);

		this.Class = Class;
	}

	/**
	 * From beginning this method run, After calling this class again, this
	 * method not run anymore.
	 */
	@Override
	public Fragment getItem(int position) {
		Fragment mFragment = null;

		if (Class.getSimpleName().equals(
				DashBoardStepsSimpleFragment.class.getSimpleName())) {
			/**
			 * View pager in Dash board page
			 */
			switch (position) {
			case Position.STEPS:
				DashBoardFragment.CASE = DashBoard.STEPS;
				mFragment = new DashBoardStepsSimpleFragment();
				break;
			case Position.DISTANCE:
				DashBoardFragment.CASE = DashBoard.DISTANCE;
				mFragment = new DashBoardDistanceSimpleFragment();
				break;
			case Position.CALORIES:
				DashBoardFragment.CASE = DashBoard.CALORIES;
				mFragment = new DashBoardCaloriesSimpleFragment();
				break;
			// case Position.ACTIVE_MINS:
			// DashBoardFragment.CASE = DashBoard.ACTIVE_MINS;
			// mFragment = new DashBoardActiveMinsSimpleFragment();
			// break;
			case Position.SLEEP:
				DashBoardFragment.CASE = DashBoard.SLEEP;
				mFragment = new DashBoardSleepSimpleFragment();
				break;
			default:
				break;
			}
		} else if (Class.getSimpleName().equals(
				DashBoardDetailStepsSimpleFragment.class.getSimpleName())) {
			/**
			 * View pager in Dash board Detail page
			 */
			switch (position) {
			case Position.STEPS:
				DashBoardFragment.CASE = DashBoard.STEPS;
				mFragment = new DashBoardDetailStepsSimpleFragment();
				break;
			case Position.DISTANCE:
				DashBoardFragment.CASE = DashBoard.DISTANCE;
				mFragment = new DashBoardDetailDistanceSimpleFragment();
				break;
			case Position.CALORIES:
				DashBoardFragment.CASE = DashBoard.CALORIES;
				mFragment = new DashBoardDetailCaloriesSimpleFragment();
				break;
			// case Position.ACTIVE_MINS:
			// DashBoardFragment.CASE = DashBoard.ACTIVE_MINS;
			// mFragment = new DashBoardDetailActiveMinsSimpleFragment();
			// break;
			case Position.SLEEP:
				DashBoardFragment.CASE = DashBoard.SLEEP;
				mFragment = new DashBoardDetailSleepSimpleFragment();
				break;
			default:
				break;
			}
		} else if (Class.getSimpleName().equals(
				WelcomeNabuSimpleFragment.class.getSimpleName())) {
			/**
			 * View pager in WelcomeNabu page
			 */
			switch (position) {
			default:
				mFragment = new WelcomeNabuSimpleFragment();
				return mFragment;
			}
		}
		return mFragment;
	}

	@Override
	public int getCount() {
		return COUNT;
	}
}